import time
from selenium import webdriver
class Driverutils:
    driver= None
    __save_cookie = None
    @classmethod
    def get_driver(cls):
        cls.driver = webdriver.Chrome()
        cls.driver.get('http://localhost/')
        cls.driver.maximize_window()
        cls.driver.implicitly_wait(30)
        return cls.driver
    @classmethod
    def close_driver(cls):
        time.sleep(5)
        cls.driver.quit()
    @classmethod
    def get_login_cookie(cls):
        cls.__save_cookie = cls.driver.get_cookies()
    @classmethod
    def modification_login_cookie(cls):
        cls.driver.delete_all_cookies()
        for cookie in cls.__save_cookie:
            cls.driver.add_cookie({'name': cookie['name'], 'value': cookie['value']})
        cls.driver.refresh()